import { _decorator, Button, Component, Label, Layout, Node } from 'cc';
import EntityBase from '../utils/EntitySystem/EntityBase';
import { BattleData } from '../Data/BattleData';
import { ProbeEventList } from '../utils/EventSystem/EventList';
const { ccclass, property } = _decorator;

@ccclass('stageButton')
export class StageButton extends EntityBase {
    public battleData : BattleData;

    public StageButtonDown : ProbeEventList = new ProbeEventList();
    
    public get label() : Label {
        return this.markedChild.GetComponent<Label>("label",Label.name);
    }
    

    public InitItem(param: any): void {
        super.InitItem(param);
        let data : BattleData = param[0];
        let parent : Node = param[1];

        this.battleData = data;
        parent.addChild(this.node);

        this.node.on(Button.EventType.CLICK,this._onButtonDown,this);

    }

    public CloseSelf(): void {
        this.node.targetOff(this);
        super.CloseSelf();
    }

    private _onButtonDown(){
        this.StageButtonDown.DoEvent(this.battleData);
    }
}


